29. 练习:算术运算符

使用算术运算的问题

使用 orders 表:

  1. 创建一个用 standard_amt_usd 除以 standard_qty 的列,查找每个订单中标准纸张的单价。将结果限制到前 10 个订单,并包含 id account_id 字段。

  2. 编写一个查询,查找每个订单海报纸的收入百分比。 只需使用以 _usd 结尾的列。 (在这个查询中试一下不使用总列)。包含 id account_id 字段。

注意 1 - 对于这个问题,即使采用正确的解决方案,也会遇到一个问题。这就是除以零。 在后面的课程学习 CASE 语句时,我们会学习不让此查询发生错误的解决方案。

**注意 2 - 上述运算符将信息合并在同一行的列中。如果要跨多行组合特定列的值,我们将使用聚合来进行此操作。稍后学习这部分内容。 **

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: sql-evaluator
  • Opened files (when workspace is loaded): n/a